function addEvent (obj, ev, fn) {
	if (!obj) {
		return;
	}
	if (obj.attachEvent) {
		obj.attachEvent('on' + ev, fn);
	}
	else {
		obj.addEventListener(ev, fn, false);
	}
}

window.onload = function () {
	var dialogContainer = document.getElementById('dialog-box');
	//对话框显示
	function showDialog () {
		//透明背景的遮罩
		var maskNode = document.createElement('div');
		var container = document.body;
		maskNode.setAttribute('class', 'pagemask');
		maskNode.setAttribute('id', 'pagemask');
		container.appendChild(maskNode);

		//对话框
		dialogContainer.setAttribute('class', 'dialog-box');
		var dHeight = dialogContainer.clientHeight;
		console.log(dHeight);
		dialogContainer.setAttribute('style', 'margin-top: -' + dHeight/2 +'px');
		maskNode.appendChild(dialogContainer);
	}

	//页面加载完成后对话框自动显示
	showDialog();
}